package thread;

public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread("hhm"){
            @Override
            public void run() {
                System.out.println(getName()+"睡一会");
                try {
                    sleep(50000000);
                } catch (InterruptedException e) {
                    System.out.println(getName()+"抛出异常");
                }
                System.out.println("醒了");
            }
        };


        Thread huang = new Thread("huang"){
            @Override
            public void run() {
                System.out.println(getName()+"huang");
                for (int i = 0; i < 5; i++) {
                    System.out.println(getName()+"80");
                    try {
                        sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                //中断lin线程的sleep
                lin.interrupt();
            }
        };

        lin.start();
        huang.start();
    }
}
